#!/bin/bash
set -e

# The root of the harvester directory
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"

mkdir -p "${ROOT_DIR}/dist"

echo  "Running unit tests"

unit_test_targets=($(find "${ROOT_DIR}/pkg" -maxdepth 1 -mindepth 1 -type d ! -path '*generated*' ! -path '*apis*' -exec echo {}/... \;))

CGO_ENABLED=1 go test \
	-tags=test \
	-race \
	-cover -coverprofile "${ROOT_DIR}/dist/coverage.out" \
	"${unit_test_targets[@]}"
